package com.mg.sms;

import java.text.SimpleDateFormat;
import java.util.Date;

import android.app.Service;
import android.content.Intent;
import android.os.Handler;
import android.os.IBinder;
import android.util.Log;

/**
 * <p>Title: com.mg.sms.MessageService</p>
 * <p>Description: 訊息服務</p>
 * <p>Copyright: Copyright (c) 2011</p>
 * <p>Company: FreeLance</p>
 * @author Jason Huang
 * @version 1.0
 */
public class MessageService extends Service{
    
    private Handler handler = new Handler();
    
    private static MessageThread messageThread = new MessageThread();

    @Override
    public IBinder onBind(Intent arg0) {
        return null;
    }

    @Override
    public void onDestroy() {
        handler.removeCallbacks(messageThread);
        super.onDestroy();
    }

    @Override
    public void onStart(Intent intent, int startId) {
        handler.postDelayed(messageThread, 5000);
        super.onStart(intent, startId);
    }
    
    private static class MessageThread extends Thread {
        @Override
        public void run() {
            Log.i("bear", new SimpleDateFormat("yyyy/MM/dd hh:mm:ss").format(new Date()));
            super.run();
        }
    }
}

